<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
>

<head th:include="header">
    <title>定时任务-编辑</title>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox-content">
        <form id="fm" class="form-horizontal"
              data-validator-option="{timely:8, focusCleanup:true, theme:'simple_bottom'}">
            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
            <input type="hidden" name="jobName" th:value="${jobName}"/>
            <input type="hidden" name="jobGroup" th:value="${jobGroup}"/>
            <div class="form-group">
                <label class="col-sm-3 control-label">cron表达式</label>
                <div class="col-sm-6">
                    <input type="text" name="cronExpression" class="form-control" placeholder="请输入cron表达式"
                           data-rule="required"></input>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="text-center">
                    <button class="btn btn-primary" type="submit">保存</button>
                    <button class="btn btn-white" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div th:include="footer"></div>
<script type="text/javascript" th:inline="javascript">


    $("#fm").validator({
        valid: function (form) {
            var me = this;
            // 提交表单之前，hold住表单，防止重复提交
            me.holdSubmit();
            $.ajax({
                url: basePath + "schedule/update",
                data: $(form).serialize(),
                type: "POST",
                dataType: 'json',
                success: function (data) {
                    if (data.success) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg(data.msg, {
                            icon: 1,
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            window.parent.location.reload();
                            parent.layer.close(index);
                        });

                    } else {
                        parent.layer.msg(data.msg, {
                            icon: 2,
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        });
                        me.holdSubmit(false);
                    }
                }
            });
        }
    });
</script>
</body>

</html>